/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package robozanalib;


import java.io.Serializable;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author juan__000
 */
public class Fase {

    public Fase(int t) {
        for(int i=0;i!=t;i++)
        players.add(new Robo());
    }
    
    private boolean occuped=false;

    public synchronized Robo[] getPlayers(){
        if(occuped)
            try {
                this.wait();
        } catch (InterruptedException ex) {
                System.out.println("ERRO NO PARAMENTO DA THREAD");
        }
        Robo[] r = new Robo[players.size()];
        for(int i=0;i!=players.size();i++){
            r[i]=players.get(i);
        }
        return r;
    }

    public synchronized void setPlayers(Robo[] players) throws InterruptedException {
        if(occuped)
            wait();
        occuped=!occuped;
        for(int i=0;i!=this.players.size();i++)
            this.players.set(i,players[i]);
        occuped=!occuped;
        notifyAll();
    }

    public GregorianCalendar getTempo() {
        return tempo;
    }

    public void setTempo(GregorianCalendar tempo) {
        this.tempo = tempo;
    }
    
    private ArrayList<Robo> players= new ArrayList();
    private GregorianCalendar tempo;
    
    
}
